package io.lvdaxian.map4.file.stream.controller;

import io.lvdaxian.map4.file.stream.common.CommonUtils;
import io.lvdaxian.map4.file.stream.common.file.FileUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.File;
import java.nio.file.Path;

@RequestMapping("/file")
@RestController
public class FileController {
  
  public final static Path COMMON_FILE_DIR = CommonUtils.getAbsolutePath("./videoDir");
  
  static {
    ClassLoader classLoader = FileController.class.getClassLoader();
    // 获取classpath的根目录
    String classpath = classLoader.getResource("").getPath();
    
    // 要创建的文件夹名称
    String folderName = "newFolder";
    
    // 创建文件夹
    File newFolder = new File(classpath + folderName);
    if (!newFolder.exists()) {
      boolean created = newFolder.mkdir();
      if (created) {
        System.out.println("Folder created successfully at: " + newFolder.getAbsolutePath());
      } else {
        System.out.println("Failed to create folder.");
      }
    } else {
      System.out.println("Folder already exists at: " + newFolder.getAbsolutePath());
    }
  }
}
